/* author: Mariana Horita
   mariana.horita@gmail.com
   file: A4E3.cs*/
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace Resolucao
{
    public partial class A4E3 : Form
    {
        private Button[,] btTela;
        private int nBt = 10;
        
        public A4E3()
        {
            InitializeComponent();
        }

        private void A4E3_Load(object sender, EventArgs e)
        {
            btTela = new MyButton[nBt, nBt];

            for (int i = 0; i < nBt; i++)
            {
                for (int j = 0; j < nBt; j++)
                {
                    btTela[i, j] = new MyButton();
                    btTela[i, j].Location = new Point(i * 50, j * 25);
                    btTela[i, j].Text = "0";

                    btTela[i, j].MouseEnter += new EventHandler(A4E3_MouseEnter);
                    btTela[i, j].MouseLeave += new EventHandler(A4E3_MouseLeave);
                    btTela[i, j].Click += new EventHandler(A4E3_Click);

                    this.Controls.Add(btTela[i, j]);
                }
            }
        }

        void A4E3_Click(object sender, EventArgs e)
        {
            MyButton bt = (MyButton)sender;
            bt.Text = (Convert.ToInt32(bt.Text) + 1).ToString();
        }

        void A4E3_MouseLeave(object sender, EventArgs e)
        {
            MyButton bt = (MyButton)sender;

            bt.Red = (Convert.ToInt32(bt.Text) * 5 % 256);
            bt.Green = (Convert.ToInt32(bt.Text) * 7 % 256);
            bt.Blue = (Convert.ToInt32(bt.Text) * 10 % 256);
            
        }

        void A4E3_MouseEnter(object sender, EventArgs e)
        {
            MyButton bt = (MyButton)sender;
            bt.BackColor = Color.Red;
        }
    }
}
